Skip to content

Conversation

@laylatichy
Copy link
Contributor

current assert for findDispatches never fails

@laylatichy laylatichy marked this pull request as draft November 13, 2025 12:45
@laylatichy
Copy link
Contributor Author

laylatichy commented Nov 13, 2025

@brendt I'll probably need your help here

test fail because in tests/Integration/Mailer/MailerTest.php

$this->eventBus->preventEventHandling();

doesnt swap EventBus instance in TestingMailer, it still resolves to GenericEventBus

because its defined earlier in src/Tempest/Framework/Testing/IntegrationTest.php setupTesters

$this->mailer = new MailTester(new TestingMailer(
eventBus: $this->container->get(EventBus::class),
));

and at that time when we get event bus its generic not the tester one

i was able to fix it like this: b3be9a6

but Im not a fan of making it public and hot swapping, maybe there is a better way

edit: actually replaced contructor with propety getter in TestingMailer

private EventBus $eventBus {
get => get(className: EventBus::class);
}

think its more sane approach

@laylatichy laylatichy force-pushed the fix/eventbus-dispatches-assert branch 5 times, most recently from ff361f3 to 4f5cb60 Compare November 13, 2025 13:14
@laylatichy laylatichy marked this pull request as ready for review November 13, 2025 13:14
@laylatichy laylatichy force-pushed the fix/eventbus-dispatches-assert branch 2 times, most recently from f4198db to 932a34d Compare November 13, 2025 13:20
@laylatichy laylatichy force-pushed the fix/eventbus-dispatches-assert branch from 932a34d to 4e3a27f Compare November 13, 2025 13:24
@innocenzi
Copy link
Member

Could you add regression tests that cover the issues you were encountering previously?

@laylatichy
Copy link
Contributor Author

laylatichy commented Nov 13, 2025

Could you add regression tests that cover the issues you were encountering previously?

added

the issue was that assertDispatched always returned false positive if no callback or count was specified because

Assert::assertNotNull(
actual: $dispatches = $this->findDispatches($event),
message: 'The event was not dispatched.',
);

$dispatches = $this->findDispatches($event) never resolved to null

@brendt brendt merged commit 82318a6 into tempestphp:main Nov 14, 2025
74 checks passed
@brendt
Copy link
Member

brendt commented Nov 14, 2025

Thanks!

@brendt brendt mentioned this pull request Nov 14, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants